package etc;

import java.util.ArrayList;
import java.util.List;
import java.util.regex.Matcher;
import java.util.regex.Pattern;

import pattern.RediffmailPatterns;

public class TestPatterns {

	public static String text = 
//		"<FORM name=loginform action=http://mail.rediff.com/cgi-bin/login.cgi method=post>"+
//		"<tr><td height=6></td></tr>"+
//		"<tr>"+
//		"<td width=10></td>"+
//		"<td width=104 class=f10><B><font color=\"#707070\">Username</font></B></td>"+
//		"<td width=4></td>"+
//		"<td colspan=3 class=f10><B><font color=\"#707070\">Password</font> <FONT class=f10 COLOR=\"#16387\">(<A HREF=\"javascript:PasswdRemindWin()\">Forgot Password?</A>)</FONT></B></td>"+
//		"</tr>"+
//		"<tr><td height=1></td></tr>"+
//		"<tr>"+
//		"<td width=10></td>"+
//		"<td width=104 class=f10><INPUT type=text style=\"MARGIN: 0px; WIDTH: 104px; FONT-FAMILY: arial,helvetica,sans-serif\" maxLength=30 size=6 name=login></td>"+
//		"<td width=4></td>"+
//		"<td width=107 class=f10><INPUT type=password  style=\"MARGIN: 0px; WIDTH: 107px; FONT-FAMILY: arial,helvetica,sans-serif\" maxLength=30 size=6 name=passwd>"+
//		"<INPUT type=hidden value=existing name=FormName>"+
//		"</td>"+
//		"<td width=4></td>"+
//		"<td width=46><INPUT type=image src=\"http://im.rediff.com/uim/news/mail_go.gif\" WIDTH=37 HEIGHT=22 BORDER=0 HSPACE=0 VSPACE=0 TITLE=\"Sign in\"></td>"+
//		"</tr>"+
//		"<tr><td height=6></td></tr>"+
//		"<tr>"+
//		"<td colspan=6 align=center>"+
//		"<table cellspacing=0 cellpadding=0 border=0 align=center>"+
//		"<tr><td class=fv10>New User? For free email &nbsp; </td>"+
//		"<td class=fv10><A HREF=\"/r/r/rsi\"><B><U>Sign Up</U></B></A></td>"+
//		"</tr>"+
//		"<tr><td height=5></td></tr>"+
//		"</table>"+
//		"</td>"+
//		"</tr>"+
//		"</FORM>";
		"http://f4plus.rediff.com/iris/Main?do=folder&folder=Inbox&login=dharapvj&session_id=4L20PK1KEKiMWvmqcnUspVwC1PVnTT0V&SrtFld=2&SrtOrd=1&MsgCnt=0&user_size=1&preloaded=1";	
	public static void main(String[] args) {
		StringBuffer loginForm = (StringBuffer) matcher(RediffmailPatterns.kPatternSession_id,text).get(0);
		System.out.println(loginForm);
	}	
	
	public static List matcher(String patternString, String searchString){
		Pattern pattern = Pattern.compile(patternString);
		Matcher matcher = pattern.matcher(searchString);
		List matcherGroup = new ArrayList() ;
//		int i = 0;
        while (matcher.find()){
        	matcherGroup.add(new StringBuffer(matcher.group()));
        }
		return matcherGroup ;
	}

}
